# 系统随机生成8个1-33的整数形成一注中奖号码，用户在控制台输入8位数字看是否中奖：
# 号码全对：一等奖
# 错一个：二等奖
# 错两个：三等奖
# 错三个：四等奖
# 尝试模拟随机购买10000注彩票对特定号码的中奖概率。
import random


def cp():
    cps = random.sample(range(1,33), 8)
    print(cps)
    return cps

def yz(cps,myCp):
    zj = 0
    for i in cps:
        for j in myCp:
            if i == j:
                zj += 1
    return (8-zj)

def xtsc(num):
    myCps = []
    for i in range(num):
        myCps.append(random.sample(range(1,33), 8))
    print(myCps)
    return myCps

if __name__ == "__main__":
    cp = cp()

    # 手动输入
    # mycp = eval(input("输入你的彩票"))
    # nums = yz(cp,mycp)
    # if nums == 0:
    #     print("一等奖")
    # elif nums == 1:
    #     print("二等奖")
    # elif nums == 2:
    #     print("三等奖")
    # elif nums == 2:
    #     print("四等奖")
    # else:
    #     print("谢谢惠顾")

    # 系统输入
    xtcp = xtsc(100000000)
    i1 = 0
    i2 = 0
    i3 = 0
    i4 = 0
    i0 = 0
    for i in xtcp:
        nums = yz(cp,i)
        if nums == 0:
            i1+=1
            print("一等奖")
        elif nums == 1:
            i2 += 1
            print("二等奖")
        elif nums == 2:
            i3 += 1
            print("三等奖")
        elif nums == 2:
            i4 += 1
            print("四等奖")
        else:
            i0 += 1
            print("谢谢惠顾")

    print("一等奖：",i1,"次")
    print("二等奖：", i2, "次")
    print("三等奖：", i3, "次")
    print("四等奖：", i4, "次")
    print("谢谢惠顾：", i0, "次")

